The exemplary embodiments disclosed herein relate to a game program and a game apparatus, and more specifically to a game program and a game apparatus for executing game processing in accordance with a movement of an input device itself.
Conventionally, a game apparatus for executing game processing in accordance with a movement of an input device itself is described in, for example, patent document 1 (Japanese Laid-Open Patent Publication No. 2001-104636). This document discloses a baseball bat-shaped input device including an acceleration sensor using a piezoelectric beeper or the like. A player performs a game operation by actually swinging the baseball bat-shaped input device. The game apparatus detects the speed of the baseball bat-shaped input device (the moving speed or the rotation speed) and reflects the detected speed on the movement of a ball in the game. Thus, the flying distance or direction of the ball in the game can be changed.
The game apparatus described in patent document 1 determines the movement of the ball using the value of the maximum moving speed of the input device. However, the strength of the swing on the ball cannot be calculated with only the speed of the input device at one point in time. The reason is that the strength of the swing is determined by factors such as the length of the stroke of the swing (time length and distance) as well as the maximum speed of the input device. With the method described in patent document 1, for example, the same result is obtained as long as the maximum speed is the same regardless of whether the stroke of the swing is longer or shorter. The strength of the swing cannot be reflected on the game.
Therefore, a feature of certain exemplary embodiments is to provide a storage medium having a game program stored thereon and a game apparatus capable of calculating the strength of the swing of an input device.
The certain exemplary embodiments have the following features. The reference numerals and additional explanations in parentheses in this section of the specification indicate the correspondence with the exemplary embodiments described later for easier understanding of the certain exemplary embodiments described herein, and should not be considered limiting in any way.
A first aspect is directed to a computer-readable storage medium having stored thereon a game program (60) executable by a computer (CPU 10) of a game apparatus (3) for executing game processing (FIG. 11) in accordance with a movement of an input device (controller 5). The game program causes the computer to execute an obtaining step (S31), a change amount calculation step (S22), an accumulated value calculation step (S23), a swing strength calculation step (S16), and a game processing step (S3). In the obtaining step, the computer obtains an acceleration (acceleration vector A or processing acceleration vector “a”) generated in at least two predetermined axial directions of the input device repeatedly. In the change amount calculation step, the computer calculates a change amount (as) of each of the accelerations obtained in the obtaining step during a predetermined time period (swing period). In the accumulated value calculation step, the computer calculates an accumulated value (s) obtained by accumulating the calculated change amounts. In the swing strength calculation step, the computer calculates a swing strength (p) of the input device based on the accumulated value. In the game processing step, the computer executes the game processing using the calculated swing strength.
In a second aspect, the input device may comprise a predetermined button. In this case, the game program may cause the computer to further execute a period setting step (S13 and S15) of setting the predetermined time period based on a pressing state of the predetermined button.
In a third aspect, the game program may cause the computer to further execute a period setting step (S13 and S15) of setting a time period in which the acceleration has a magnitude of equal to or larger than a predetermined magnitude as the predetermined period.
In a fourth aspect, in the accumulated value calculation step, the computer may calculate the accumulated value each time the change amount is calculated, such that when the change amount is smaller than a reference value, the accumulated value is smaller than a previous accumulated value (expression (3)). In this case, in the swing strength calculation step, the computer calculates the swing strength, such that as the maximum accumulated amount (s_max) calculated during the predetermined period is larger, the swing strength is greater (expression (5)).
In a fifth aspect, in the accumulated value calculation step, the computer may calculate, each time the change amount is calculated, a new accumulated value by adding the change amount to a value obtained by subtracting a predetermined amount from the current accumulated value (expression (5)). In this case, in the swing strength calculation step, the computer calculates the swing strength, such that as the maximum accumulated amount calculated during the predetermined period is larger, the swing strength is greater.
In a sixth aspect, the predetermined amount may be a predetermined ratio of the current accumulated value.
In a seventh aspect, the input device may comprise an acceleration sensor for detecting an acceleration in at least two predetermined axial directions. In this case, in the obtaining step, the computer may calculate, as an acceleration to be obtained, a vector (processing acceleration vector) which changes so as to follow a vector represented by data output from the acceleration sensor.
In an eighth aspect, the input device may comprise an acceleration sensor for detecting an acceleration in at least two predetermined axial directions. In this case, in the obtaining step, the computer may calculate, as an acceleration to be newly obtained, a vector internally dividing a range between a vector representing the current acceleration and a vector represented by data output from the acceleration sensor.
In a ninth aspect, the game program may cause the computer to further execute a magnitude calculation step (S26). In the magnitude calculation step, the computer calculates a magnitude of each of the accelerations obtained during the predetermined period. In the swing strength calculation step, the computer may calculate the swing strength of the input device based on the accumulated value and the acceleration magnitudes (expression (5)).
In a tenth aspect, in the swing strength calculation step, the computer may calculate the swing strength of the input device based on the maximum value (av_max) of the acceleration magnitudes calculated during the predetermined period and the accumulated value. In an eleventh aspect, in the swing strength calculation step, the computer may calculate the swing strength of the input device based on the accumulated value and the acceleration magnitudes.
The certain exemplary embodiments may be provided in the form of a game apparatus having equivalent functions to those of the game program for executing the above-described steps.
According to the first aspect, the change amount of the acceleration of the input device during the swing period is calculated. Based on the accumulated value obtained by accumulating the change amounts, the swing strength is calculated. By using the change amount, the swing strength, which reflects the length of time in which the input device is actually swung and also the speed at which the input device is actually swung, is calculated. Thus, according to the first aspect, the swing strength of the input device can be accurately calculated.
According to the second aspect, the swing period is determined based on the pressing state of the button. Therefore, the player himself/herself can determine the swing period. As a result, it does not occur that the operation of swinging the input device is performed against the intention of the player merely because the player has inadvertently swung the input device. This improves the operability of swinging the input device.
According to the third aspect, the time period in which the acceleration is equal to or larger than the predetermined value is set as the swing period. Unless the player actually performs an operation of swinging the input device, the swing period is not set. Therefore, it does not occur that the operation of swinging the input device is performed against the intention of the player. This improves the operability of swinging the input device.
According to the fourth aspect, when the change amount is smaller than the reference value, the maximum accumulated value is not updated. Even if the input device moves very slightly after the player finishes swinging the input device, such a small motion of the input device is not reflected on the swing strength. According to the fourth aspect, the swing strength of the input device is accurately calculated. The fourth aspect is especially effective in the case where the swing period which is set in the game apparatus does not match the time period from the start until the end of the swing of the controller 5 as in the second aspect.
According to the fifth aspect, a new accumulated value is calculated by adding a newly calculated change amount to a value obtained by subtracting a predetermined amount from the current accumulated value. Like in the fourth aspect, the accumulated value is calculated to be smaller than the previous accumulated value when the change amount is smaller than the reference value (“predetermined value” in the fifth aspect). According to the fifth aspect, like the fourth aspect, the swing strength of the input device can be calculated accurately.
According to the sixth aspect, an amount which is a predetermined ratio of the current accumulated value is set as the predetermined amount. Therefore, the predetermined value can be calculated, with the current accumulated value being reflected.
According to the seventh aspect, a vector which changes so as to follow the vector represented by the data output from the acceleration sensor is used as a vector representing the acceleration. By this, it can be avoided that the acceleration exceeds the detection limit of the acceleration sensor. Thus, the swing strength of the input device can be calculated more accurately.
According to the eighth aspect, a new acceleration is calculated as a vector internally dividing a range between the vector representing the current acceleration and the vector represented by data output from the acceleration sensor. Like in the seventh aspect, the new acceleration vector changes so as to follow the vector represented by the data output from the acceleration sensor. According to the eighth aspect, like the seventh aspect, it can be avoided that the acceleration exceeds the detection limit of the acceleration sensor. Thus, the swing strength of the input device can be calculated more accurately.
According to the ninth aspect, the swing strength of the input device is calculated based on the magnitude of the acceleration in addition to the accumulated value. Even when the swing motion of the input device is not easily reflected on the accumulated value (when the input device is swung slowly), such a motion of the input device can be reflected on the magnitude of the acceleration vector. According to the ninth aspect, the swing strength of the input device can be calculated accurately even in such a case.
According to the tenth aspect, the swing strength of the input device is calculated using the maximum acceleration magnitude calculated during the swing period. Therefore, the acceleration magnitude can be reflected on the swing strength accurately.
According to the eleventh aspect, a change amount between the acceleration obtained most newly and the acceleration obtained immediately previously can be calculated accurately.
These and other features, aspects and advantages of certain exemplary embodiments will become more apparent from the following detailed description of the exemplary embodiments when taken in conjunction with the accompanying drawings.